package com.cyy.springbootinit.model.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum EquipmentTypeConst {
    ElectricityEquipment("电表",2),
    WaterEquipment("水表",1);

    private final String text;

    private final Integer value;
    EquipmentTypeConst(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    public static List<Integer> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    public static EquipmentTypeConst getEnumByValue(Integer value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (EquipmentTypeConst anEnum : EquipmentTypeConst.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }
    public Integer getValue() {
        return value;
    }

    public String getText() {
        return text;
    }
}
